from selenium import webdriver
from selenium.webdriver.common.by import By
from pynput import mouse,keyboard
import time
from selenium.webdriver.common.action_chains import ActionChains

def five8(url,phone):
    browser = webdriver.Chrome()
    browser.get(url)
    time.sleep(2)
    browser.find_element(By.XPATH,"/html/body/div[2]/div[3]/div[3]/div[2]/div[1]/span[1]").click()
    time.sleep(2)
    browser.find_element(By.ID,"mask_body_item_phonenum").send_keys(phone)
    time.sleep(2)
    browser.find_element(By.ID,"mask_body_item_getcode").click()
    print("发送陈工")
    #time.sleep(10)
    #browser.find_element(By.ID,"mask_body_item_getvoicecode").click()
    time.sleep(2)
    print("58执行完成")


def ttpai(url,phone):
    browser = webdriver.Chrome()
    browser.get(url)
    time.sleep(2)
    browser.find_element(By.XPATH,"/html/body/div[1]/div[2]/div/div/div[1]/div[1]/div/div/div[2]/div/input").send_keys(phone)
    browser.find_element(By.XPATH,"/html/body/div[1]/div[2]/div/div/div[1]/div[1]/div/button").click()
    time.sleep(600)


def xiaohongshu(url,phone):
    browser = webdriver.Chrome()
    browser.get(url)
    time.sleep(5)
    browser.find_element(By.XPATH,"/html/body/div[1]/div[1]/div/div[1]/div[3]/div[3]/form/label[1]/input").send_keys(phone)
    browser.find_element(By.XPATH,"/html/body/div[1]/div[1]/div/div[1]/div[3]/div[3]/form/label[2]/span").click()
    print("小红书执行完成")

def douyin():
   browser = webdriver.Chrome()
   browser.get("https://www.douyin.com/user/self")
   time.sleep(5)
   browser.find_element(By.XPATH,"")
   print("抖音执行完成")

def taobao(url,phone):
    browser = webdriver.Chrome()
    browser.get(url)
    time.sleep(5)
    browser.find_element(By.XPATH,"/html/body/div/div[2]/div[3]/div/div/div/div[2]/div/div[1]/a[2]").click()
    browser.find_element(By.ID,"fm-sms-login-id").send_keys(phone)
    browser.find_element(By.XPATH,"/html/body/div/div[2]/div[3]/div/div/div/div[2]/div/form/div[2]/div[3]/a").click()
    time.sleep(4)
    print("淘宝执行完成")
    # for i in range(100):
    #     time.sleep(60) ##休眠60苗
    #     browser.find_element(By.XPATH,"/html/body/div/div[2]/div[3]/div/div/div/div[2]/div/form/div[2]/div[3]/a").click()

def jingdong(url,phone):
    browser = webdriver.Chrome()
    browser.get(url)
    time.sleep(2)
    browser.find_element(By.ID,"sms-login").click()
    browser.find_element(By.ID,"mobile-number").send_keys(phone)
    browser.find_element(By.ID,"send-sms-code-btn").click()
    time.sleep(2)
    print("京东执行完成")

def xiaomi(url,phone):
    browser = webdriver.Chrome()
    browser.get(url)
    time.sleep(5)
    browser.find_element(By.XPATH,"/html/body/div[1]/div/div/div[2]/div/div/div[2]/div/div[2]/div[2]/div/div[1]/form/div[1]/div[1]/div/div[2]/div/input").send_keys(phone)
    browser.find_element(By.XPATH,"/html/body/div[1]/div/div/div[2]/div/div/div[2]/div/div[2]/div[2]/div/div[1]/form/div[1]/div[3]/label/span[1]/input").is_selected()
    time.sleep(2)
    browser.find_element(By.XPATH,"/html/body/div[1]/div/div/div[2]/div/div/div[2]/div/div[2]/div[2]/div/div[1]/form/div[1]/button").click()
    time.sleep(10)
    print("小米执行完成")

def baidu(url,phone):
    browser = webdriver.Chrome()
    browser.get(url)
    time.sleep(5)
    browser.find_element(By.ID,"s-top-loginbtn").click()
    time.sleep(1)
    browser.find_element(By.ID,"TANGRAM__PSP_11__changeSmsCodeItem").click()
    browser.find_element(By.ID,"TANGRAM__PSP_11__smsPhone").send_keys(phone)
    browser.find_element(By.ID,"TANGRAM__PSP_11__smsTimer").click()
    time.sleep(2)
    print("百度执行完成")

##根据鼠标位置 疯狂执行打字 按下enter和松开enter按钮
def shubiao():
    time.sleep(5)
    m_mouse = mouse.Controller()     ##创建一个鼠标
    m_keyboard = keyboard.Controller()##创建一个键盘
    m_mouse.position = (850,670) ##将鼠标移动到指定位置
    m_mouse.click(mouse.Button.left) ##点击鼠标左键
    # while(True):
    for i in range(100):
        m_keyboard.type(str(i))  ##打字
        m_keyboard.press(keyboard.Key.enter) ##按下enter
        m_keyboard.release(keyboard.Key.enter)  ##松开41
        time.sleep(0.1)


phone = 17855055250
# phone=15601750880

# shubiao()  ##循环点击发送消息

def yidong(url,phone):
    browser = webdriver.Chrome()
    browser.get(url)
    time.sleep(2)
    browser.find_element(By.ID,"J_pc").click()
    browser.find_element(By.ID,"sms_name").send_keys(phone)
    time.sleep(8)

def shunfeng(url,phone):
    browser = webdriver.Chrome()
    browser.get(url)
    time.sleep(3)
    browser.find_element(By.XPATH,"/html/body/div[1]/div/div/div[2]/div/span[1]/span").click()
    time.sleep(1)
    browser.find_element(By.XPATH,"/html/body/div[7]/div/div[1]/div[1]/div[3]/span").click()
    time.sleep(1)
    browser.find_element(By.XPATH,"/html/body/div[7]/div/div[2]/div/div[1]/form/div[1]/input").send_keys(phone)
    browser.find_element(By.XPATH,"/html/body/div[7]/div/div[2]/div/div[2]/div").click()
    browser.find_element(By.XPATH,"/html/body/div[7]/div/div[2]/div/div[1]/form/div[2]/input[2]").click()
    time.sleep(5)

def yuantong(url,phone):
    browser = webdriver.Chrome()
    browser.get(url)
    time.sleep(1)
    browser.find_element(By.XPATH,"/html/body/div[1]/div/div/div[1]/div[1]/div[2]/div[1]/form/div[1]/div/div/input").send_keys(phone)
    browser.find_element(By.XPATH,"/html/body/div[1]/div/div/div[1]/div[1]/div[2]/div[1]/form/div[3]/div/div/button").click()
    time.sleep(10)


def laodongnew(url,phone):
    browser = webdriver.Chrome()
    browser.get(url)
    time.sleep(1)
    browser.find_element(By.XPATH,"/html/body/div/div[2]/div[2]/div[2]/div[2]/form/div[1]/input").send_keys(phone)
    time.sleep(10)
    browser.find_element(By.XPATH,"/html/body/div/div[2]/div[2]/div[2]/div[2]/form/div[3]/span").click()


# xiaohongshu("https://www.xiaohongshu.com/explore",phone)


laodongnew("https://www.clssn.com/login.html?type=1",phone)

yuantong("https://ec.yto.net.cn/userlogin?redirectTo=https%3A%2F%2Fwww.yto.net.cn%2F",phone)

shunfeng("https://www.sf-express.com/chn/sc",phone)



yidong("https://login.10086.cn/login.html?channelID=12003&backUrl=https://shop.10086.cn/i/?f=home",phone)
# baidu("https://www.baidu.com/",phone);
xiaomi("https://cn.account.xiaomi.com/fe/service/login/phone?_locale=zh_CN&source=&region=CN&sid=passport&qs=_locale%3Dzh_CN&callback=https%3A%2F%2Faccount.xiaomi.com&_uRegion=CN",phone)
jingdong("https://passport.jd.com/new/login.aspx",phone)
five8("https://passport.58.com/login",phone)
taobao("https://login.taobao.com/",phone)
# ttpai("https://cms.ttpai.cn/newcar/24927/",phone)


print("为什么关闭浏览器")

time.sleep(60*10)